
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>用户列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/lib/layui/css/layui.css">
    <script src="/static/lib/layui/layui.js"></script>
</head>
<body>
 <hr class="layui-border-blue">
<form class="layui-form" action="" id="searchForm">
    <div class="layui-form-item">
    <br>
        <div class="layui-inline" style="margin-left:750px">
            <div class="layui-input-inline">
                <input type="tel" name="ispay" id="ispay" autocomplete="off" class="layui-input" placeholder="过滤">
            </div>
        </div>
        <div class="layui-inline">
            <button type="submit" class="layui-btn layui-btn-normal">搜索&nbsp;<i class="layui-icon layui-icon-search" ></i></button>
        </div>
    </div>
    </div>
</form>

<table class="layui-hide" id="test" lay-filter="test" ></table>

<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container" style="float: right">
          <button class="layui-btn layui-btn-normal  layui-btn-sm data-add-btn" lay-event="getCheckuser"> <i class="layui-icon" >&#xe654;</i>添加用户</button>
    </div>
</script>
<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-sm  layui-btn-normal" lay-event="more">编辑<i class="layui-icon layui-icon-down"></i></a>
</script>

<script>
    var $ ,layer,table,dropdown;
    layui.use(['table','form','dropdown'], function(){
        table=layui.table;
         $=layui.jquery;
        layer=layui.layer;



        table.render({
            elem: '#test'
            ,url:'http://127.0.0.1:8000/zgh0381/group_addjson/'
            ,toolbar: '#toolbarDemo'
            ,title: '用户列表'
            ,totalRow: true
            ,cols: [
                [{type: 'checkbox', fixed: 'left'}
                 ,{field:'name', title:'用户名', width:100, fixed: 'left'}
                 ,{field:'email', title:'邮箱', width:200}
                  ,{field:'id', title:'用户标识', width:300}
                  ,{field:'enabled', title:'已启用', width:100}

            ]
            ]
            ,page: true
            ,limit:10
            ,limits:[10,11,12,13]
            ,id:'orderTable'
        });



        //工具栏事件
        table.on('toolbar(test)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id);
            switch(obj.event){
                case 'getCheckuser':
                    var data = checkStatus.data;
                    var user_info = JSON.stringify(data);
                    //传递选中的值
                    $.ajax({
                    url: "/zgh0381/group_adduser/",  // 请求的地址
                    type: "post",  // 请求方式
                    // 请求时传递过去的数据
                    data:{"user_info":user_info},
                    dataType: "json",  // 返回的数据格式
                    async: true,  // 异步的ajax
                }).success(function (data) {
                    if(data.res == 1) {
                        layer.confirm('添加成功!', {icon: 1, title: '添加成功'}, function (index) {
                             layer.closeAll();
                        })
                    }
                    else if(data.res == 0){
                       layer.alert('添加失败!');
                    }

                })




                    break;
            };
        });




    });




    function doSearch() {
        //通过jquery获取参数的值
        var name=$("#name").val();
        var providername=$("#providername").val();
        var ispay=$("#ispay").val();

        table.reload('orderTable', {
            where: {
                name:name,
                providername:providername,
                ispay:ispay
            },page: {
                curr:1
            }
        });

    }


  layui.config({
        base: '/static/dist/'
    }).extend({
        notice: 'notice'
    });




</script>

</body>
</html>